package com.gec.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.gec.pojo.Article;
import com.gec.pojo.User;
import com.gec.service.ArticleService;
import com.gec.service.ReplyService;
import com.gec.service.UserService;

@Controller("replyController")
public class ReplyController {
	@Autowired
	ReplyService rs;
	@Autowired
	ArticleService articleService;
	@Autowired
	UserService us;
	
	@RequestMapping("/reply")
	public String wantPost(String text,HttpServletRequest req,HttpServletResponse resp) {
		Article art = (Article) req.getSession().getAttribute("article");
		User user = (User) req.getSession().getAttribute("session_user");
		String name = user.getName();
		us.expUP((user.getExp()+50),name);
		rs.replyArticle(art.getAid(),text,user.getName());
		return "redirect:data?id=" + art.getAid();
	}
}
